﻿using AiBLSmartEdu.Module.Chemistry.API.Configurations;
using AiBLSmartEdu.Module.Chemistry.API.Hubs;
using FrameworkCore.Constants;
using FrameworkCore.Modules.Startups;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using System.Text;

namespace AiBLSmartEdu.Module.Chemistry.API;

public partial class AiBLSmartEduStartup : IAiBLSmartEduStartup
{
    public int Order => 3000;

    public void Configure(IApplicationBuilder application)
    {
        // 启用身份验证
        application.UseAuthentication();
        application.UseAuthorization();

        // 执行由路由中间件选择的端点
        application.UseEndpoints(endpoints =>
        {
            endpoints.MapHub<NotificationHub>("/chemistry/notification");
        });
    }

    public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
    {
        var config = ConfigurationsExtensions.AddJsonFile("smartchemistrysettings");
        services.Configure<SmartChemistrySettings>(config.GetSection(SmartChemistrySettings.Key));

        services.AddSignalR();
    }
}

